package com.extra_archive.framework.core.mvc.view 
{
	import com.extra_archive.framework.core.mvc.controller.IController;
	import com.extra_archive.framework.core.mvc.controller.IkeyboardController;
	import com.extra_archive.framework.core.mvc.model.IModel;

	import flash.events.KeyboardEvent;

	public class KeyboardInputView extends CompositeView {
		public function KeyboardInputView(model : IModel = null, controller : IController = null) {
			super(model, controller);
			
			registerListener();
		}

		
		//==================================================================
		////////////////////////////////    PROPERTY    ///////////////////////////////////////////////////
		//==================================================================
				 
				 
				 
				 
		//==================================================================
		////////////////////////////////    PUBLIC METHOD    ////////////////////////////////////////////
		//==================================================================
				
				
				
				
		//==================================================================
		////////////////////////////////    EVENT LISTENER    ////////////////////////////////////////////
		//==================================================================
		public function onKeyUpHandler(event : KeyboardEvent) : void {
			(_controller as IkeyboardController).keyUpHandler(event);
		}

		public function onKeyDownHandler(event : KeyboardEvent) : void {
			(_controller as IkeyboardController).keyDownHandler(event);
		}			

		
		
		//==================================================================
		////////////////////////////////    PRIVATE METHOD    ///////////////////////////////////////////
		//==================================================================

		public function registerListener() : void {
			_model.applicationContainer.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownHandler,false,0,true);
			_model.applicationContainer.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpHandler,false,0,true);
		}
	}
}
